<template>
  <div class="app-container">
    <el-row>
      <el-col :span="24">
        <el-form ref="ruleForm" :model="form" :rules="rules" label-position="top" rel="operateFrom">
          <el-form-item label="" prop="remarks">
            <el-input type="textarea" ref="textarea" rows="4" auto-complete="off" v-model="form.remarks" size="medium" placeholder="请输入备注内容"></el-input>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
    <span slot="footer" class="dialog-footer">
      <el-button class="width100 assign-prize-cancle" size="medium" @click="cancel">取消</el-button>
      <el-button class="width100" size="medium" type="primary" @click="save">确定</el-button>
    </span>
  </div>
</template>

<script>
import form from '@/mixins/form';
import { addPremierLeagueLogRemark } from '@/services/api/activity';

export default {
  mixins: [form],
  props: ['rowData'],
  data() {
    return {
      // limitFlag: true, // 防止多次提交
      form: {
        id: this.rowData.id,
        remarks: this.rowData.remarks,
      },
      rules: {
        remarks: [
          { max: 255, message: '备注不能超过255个字', trigger: 'blur' },
        ],
      },
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.$refs.textarea.focus();
    });
    this.bindSave(addPremierLeagueLogRemark, 'saveForm', 'form', {
      afterSuccess: () => {
        this.$emit('refresh');
        this.cancel();
      },
    });
  },
  // watch: {
  //   'form.remarks': function (val) {
  //     if (!_.isUndefined(val)) {
  //       this.limitFlag = true;
  //     }
  //   },
  // },
  methods: {
    save() {
      // if (!this.limitFlag) {
      //   return;
      // }
      // this.limitFlag = false;
      this.doSave({ action: 'saveForm', form: 'ruleForm' });
    },
    cancel() {
      this.$emit('input', false);
    },
  },
};
</script>

<style lang="scss" scoped>
  .app-container{
    padding-top: 0;
    text-align: center;
  }
  .width100{
    width: 100px;
  }
  .assign-prize-cancle{
    margin: 10px 40px 0 0;
  }
</style>
